const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');

const Review = sequelize.define('Review', {
    id: {
        type: DataTypes.INTEGER,
        primaryKey: true,
        autoIncrement: true
    },
    woo_id: {
        type: DataTypes.INTEGER,
        unique: true,
        allowNull: false
    },
    product_id: {
        type: DataTypes.INTEGER,
        allowNull: false
    },
    customer_name: {
        type: DataTypes.STRING,
        allowNull: false
    },
    rating: {
        type: DataTypes.INTEGER,
        allowNull: false,
        validate: {
            min: 1,
            max: 5
        }
    },
    comment: {
        type: DataTypes.TEXT
    },
    sentiment_score: {
        type: DataTypes.FLOAT,
        defaultValue: 0
    },
    sentiment_label: {
        type: DataTypes.ENUM('positive', 'neutral', 'negative'),
        defaultValue: 'neutral'
    },
    review_date: {
        type: DataTypes.DATE,
        allowNull: false
    },
    is_analyzed: {
        type: DataTypes.BOOLEAN,
        defaultValue: false
    }
});

module.exports = Review;
